package com.cheng.example.geektime.designpatterns.j50.io;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Arrays;


/**
 *
 *
 *
 * 子类复用父类中模板方法定义的流程代码
 *
 *
 * inputStream读取流到字节缓冲区
 */
public class Test {
    public static void main(String[] args) throws IOException {
        byte[] bytes = new byte[10];

        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = (byte) i;
        }

        ByteArrayInputStream inputStream1 = new ByteArrayInputStream(bytes);

        byte[] bytes1 = new byte[10];
        System.out.println(inputStream1.read(bytes1, 2, 5));
        for (byte b : bytes1) {
            System.out.println(b);
        }
        Arrays.toString(bytes1);
    }
}
